package org.huawei.controller;

import javafx.stage.Stage;
import org.huawei.dao.SubmissionDao;
import org.huawei.model.domain.Submission;
import org.huawei.annotations.RateLimit;

import java.sql.SQLException;
import java.util.List;

public class SubmissionController {
    private Stage stage;
    private SubmissionDao submissionDao;

    public SubmissionController(Stage stage) {
        this.stage = stage;
        this.submissionDao = new SubmissionDao();
    }

    @RateLimit
    public List<Submission> selectSubmissionByHomeworkId(int homeworkId) throws SQLException {
        return submissionDao.selectSubmissionByHomeworkId(homeworkId);
    }

    @RateLimit
    public void updateSubmissionInDatabase(Submission submission) throws SQLException {
        submissionDao.updateSubmissionInDatabase(submission);
    }

    @RateLimit
    public void submitHomework(Submission submission) throws SQLException {
        submissionDao.submitHomework(submission);
    }
}
